package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zhaojian
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private DtsPermissionMapper permissionMapper;

    @Override
    public Set<String> findPermByRoleIds(Integer[] ids) {
        Set<String> permSet = new HashSet<>();

        QueryWrapper<DtsPermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role_id", ids);

        List<DtsPermission> list = permissionMapper.selectList(queryWrapper);

        if (list != null) {
            for (DtsPermission dtsPermission : list) {
                permSet.add(dtsPermission.getPermission());
            }
        }
        return permSet;
    }

}
